package com.bw.zg3park2212.fangke

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.entity.FangAddParam
import com.bw.base.entity.FangEntityItem
import com.bw.base.mvvm.BaseActivity
import com.bw.zg3park2212.R
import com.bw.zg3park2212.databinding.ActivityFangXiangBinding
import dagger.hilt.android.AndroidEntryPoint
import java.text.SimpleDateFormat

@AndroidEntryPoint
@Route(path = "/app/FangXiangActivity")
class FangXiangActivity : BaseActivity<ActivityFangXiangBinding,FangViewModel>() {
    @Autowired
    lateinit var fxid:FangEntityItem
    override fun intitView() {
        ARouter.getInstance().inject(this)
      viewmodel.getfangXiang(fxid.id)
    }

    override fun intitData() {
        viewmodel.fangXiangSuccse.observe(this){
            binding.fxVisitorName.text="访客姓名:"+it.visitorName
            binding.fxPhoneNumber.text="手机号码:"+it.phoneNumber
            binding.fxIdNumber.text="身份证号:"+it.idNumber
            binding.fxAppointmentTime.text="预约时间:"+it.appointmentTime
            binding.fxPurpose.text="来访目的:"+it.purpose
            binding.fxPlateNumber.text="车牌号:"+it.plateNumber
            if (it.visitStatus=="待审核"){
                binding.tv1.setTextColor(resources.getColor(R.color.color_kongxian))
            }else if (it.visitStatus=="已通过"){
                binding.tv1.setTextColor(resources.getColor(R.color.color_kongxian))
                binding.tv2.setTextColor(resources.getColor(R.color.color_kongxian))
            } else if (it.visitStatus=="已完成"){
                binding.tv1.setTextColor(resources.getColor(R.color.color_kongxian))
                binding.tv2.setTextColor(resources.getColor(R.color.color_kongxian))
                binding.tv3.setTextColor(resources.getColor(R.color.color_kongxian))
            }else{
                binding.tv4.setTextColor(resources.getColor(R.color.color_kongxian))
            }
            binding.btn1.setOnClickListener {
                var fangAddParam=FangAddParam()
                fangAddParam.visitStatus="驳回"
                fangAddParam.visitorName=fxid.visitorName
                fangAddParam.purpose=fxid.purpose
                fangAddParam.phoneNumber=13988445533
                fangAddParam.appointmentTime= SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis())
                viewmodel.getfangUp(fxid.id,fangAddParam)
            }
            binding.btn2.setOnClickListener {
                var fangAddParam=FangAddParam()
                fangAddParam.visitStatus="已通过"
                fangAddParam.visitorName=fxid.visitorName
                fangAddParam.purpose=fxid.purpose
                fangAddParam.phoneNumber=13988445533
                fangAddParam.appointmentTime= SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis())
                viewmodel.getfangUp(fxid.id,fangAddParam)
            }
            binding.btn3.setOnClickListener {
                var fangAddParam=FangAddParam()
                fangAddParam.visitStatus="已完成"
                fangAddParam.visitorName=fxid.visitorName
                fangAddParam.purpose=fxid.purpose
                fangAddParam.phoneNumber=13988445533
                fangAddParam.appointmentTime= SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis())
                viewmodel.getfangUp(fxid.id,fangAddParam)
            }
        }
        viewmodel.fangUpSuccse.observe(this){
            ToastUtils.showLong("修改成功")
            finish()
        }
    }

}